package com.zretc.dao;

import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.zretc.entity.Author;

public interface AuthorMapper {
	/**
	 * 根据authorid来查作者
	 * @param authorid
	 * @return
	 */
	@Select(value="select authorid,authorname from author where authorid=#{authorid}")
	public Author selectAuthor(int authorid);
	
	
	/**
	 * 查询的是Authormapper的这个方法，得到的也是Author对象;
	 * @param authorid
	 * @return
	 */
	@Select(value="select authorid,authorname from author where authorid=#{authorid}")
	@Results(value= {
			@Result(property="authorid",column="authorid"),
			@Result(property="authorname",column="authorname"),
			@Result(property="blogs",column="authorid",many = @Many(select="com.zretc.dao.BlogMapper.selectBlogByAuthorId"))
	})
	public Author selectAuthorById(int authorid);
}
